<?
include('inc_security.php');

$type		= getValue('type', 'str', 'GET', '');
$record_id	= getValue('record_id');
$redirect	= getValue('redirect', 'str', 'GET', base64_encode('listing.php'));
$redirect	= base64_decode($redirect);

$db_check = new db_query('SELECT ' . $gs_fieldupload . ' FROM ' . $gs_table . ' WHERE ' . $id_field . ' = ' . $record_id . ' AND lang_id = ' . $lang_id);
if ($check = mysql_fetch_array($db_check->result))
{
	if ($check[$gs_fieldupload] != '')
	{
		delete_file($gs_filepath, $check[$gs_fieldupload]);
	}
	if ($type == '')
	{
		$query_str = 'DELETE FROM ' . $gs_table . ' WHERE ' . $id_field . ' = ' . $record_id;
	}
	else
	{
		$query_str = 'UPDATE ' . $gs_table . ' SET ' . $gs_fieldupload . ' = NULL WHERE ' . $id_field . ' = ' . $record_id;
	}
	$db_execute = new db_execute($query_str);
	unset($db_execute);
}
unset($db_check);
redirect($redirect);
?>